/**
 * create by young (young2f@outlook.com) on 2023/5/1
 */
'use strict';
const model = require('../base/modelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmc');
  const json = {
    tenantCode: { type: 'string', required: true, desc: '租户编码' },
    tenantName: { type: 'string' },
    devices: { type: Array, desc: '绑定设备' },
    meters: { type: Array, desc: '绑定仪表' },
    employees: { type: Array, desc: '绑定人员' },
  };

  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('Organization', _schema);
};
